﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using IllusionUtility.GetUtility;
using MMD.VMD;
using RootMotion;
using RootMotion.FinalIK;
using Studio;
using UnityEngine;

namespace WzhAddon
{
	public class HSVMDAnimationController : MonoBehaviour
	{
		public OCIChar studioChara;
		public ChaControl charInfo;
		public bool isLipSync;
		public bool isBasePos;
		public bool isUseSlot;
		public bool isWaistLeg;
		private string fm = "f";
		private string _shoulderKey;
		private string _armUpKey;
		private string _armLowKey;
		private string clipname;
		private float _speed = 1f;
		public float scale = 0.085f;
		public Vector3 centerBasePos = new Vector3(0f, 8f, 0f);
		private float scaleBase = 0.085f;
		private Vector3 centerBasePosBase = new Vector3(0f, 8f, 0f);
		public Vector3 hipPositionAdjust = new Vector3(0f, 0f, 0f);
		public Vector3 slotPositionAdjust = new Vector3(0f, 0.025f, 0f);
		public bool enableIK = true;
		public bool enableIK2 = true;
		public bool enableIK3;
		private bool ikSwitch = true;
		public Dictionary<string, string> boneNameMap;
		public Transform t_centor;
		public Transform t_slot;
		private Transform t_height;
		public Transform t_hips;
		private Transform t_leftHeel;
		private Transform t_rightHeel;
		public Transform t_leftFoot;
		public Transform t_rightFoot;
		public Transform t_leftFootIK;
		public Transform t_rightFootIK;
		public Transform t_leftToe;
		public Transform t_rightToe;
		public Transform t_leftToeIK;
		public Transform t_rightToeIK;
		private Transform t_leftLeg;
		private Transform t_rightLeg;
		private Transform t_leftKnee;
		private Transform t_rightKnee;
		private const string TOE_IK_NAME_BASE = "_pv_toe_";
		public HSModelBaselineData HSModelBaseline = new HSModelBaselineData();
		private DefaultCharaAnimOverride animeOverride;
		public IKWeightData IKWeight = new IKWeightData();
		public QuickAdjust quickAdjust;
		public string lastAdjustedBone;
		public BoneAdjustment lastModifiedAdjustment;
		public Dictionary<string, BoneAdjustment> boneAdjust = new Dictionary<string, BoneAdjustment>();
		public string lastLoadedVMD;
		public Animation animationForVMD;
		private bool vmdAnimEnabled;
		private bool loop;
		private IKMorphFix ikMorphFix;
		public VMDFormat.IKSetList ikSetListVMD;
		public bool isLeftFootIK;
		public bool isRightFootIK;
		public bool isLeftToeIK;
		public bool isRightToeIK;
		public int currentSetNo;
		private string[] lipStringList = new string[] { "あ", "い", "う", "お" };

		private int[] lipNoList;
		public VMDFormat.SkinList skinListVMD;
		private bool vmdLipEnabled;
		private bool lipAudioEnabled;
		private AudioSource audioSrc;
		public string lastLipPath;
		public bool isLipDelay;
		public float lipDelayTime;
		private CCDIK lToeIK;
		private CCDIK rToeIK;
		public bool isSaveVMD;

		public bool VMDAnimEnabled
		{
			get { return this.vmdAnimEnabled; }
			set
			{
				if (this.vmdAnimEnabled == value) return;
				if (value)
				{
					if (this.animeOverride.DefaultAnimeEnabled == false) return;
					this.animeOverride.Aquire(this);
					this.vmdAnimEnabled = true;
					this.OnVMDAnimEnabledChanged();
					if (this.isLipSync && this.lipAudioEnabled)
						this.charInfo.human.lipSync.SetAudioSource(this.audioSrc);
				}
				else
				{
					if (this.t_centor != null) this.t_hips.parent = this.t_height;
					this.animeOverride.Release(this);
					if (this.animeOverride.DefaultAnimeEnabled == false) return;
					this.vmdAnimEnabled = false;
					this.OnVMDAnimEnabledChanged();
					if (this.audioSrc != null) this.audioSrc.Stop();
					this.charInfo.human.lipSync.SetAudioSource(null);
				}
			}
		}
		public float speed
		{
			get { return this._speed; }
			set
			{
				if (this._speed == value) return;
				this._speed = value;
				this.SetSpeed(this._speed);
			}
		}
		public bool Loop
		{
			get { return this.loop; }
			set
			{
				if (this.loop == value) return;
				if (this.clipname != null)
					this.GetAnimation()[this.clipname].clip.wrapMode = value ? WrapMode.Loop : WrapMode.Once;
				this.loop = value;
			}
		}

		public void Init(OCIChar studioChara, ChaControl charInfo)
		{
			this.studioChara = studioChara;
			this.charInfo = charInfo;
			this.isLipSync = true;
			this.isBasePos = true;
			this.isUseSlot = true;
			this.isWaistLeg = true;
			this.vmdLipEnabled = true;
			this.lipAudioEnabled = false;
			this.animeOverride = DefaultCharaAnimOverride.Get(studioChara);
			this.ikMorphFix = IKMorphFix.Get(studioChara.charInfo);
			if (charInfo.sex == 1)
			{
				this.fm = "f";
				float num = charInfo.human.customParam.body.shapeVals[0];
				this.centerBasePos = new Vector3(0f, 8f, 0f);
				this.hipPositionAdjust = new Vector3(0f, 1.28f + num * 0.032f, 0f);
				this.slotPositionAdjust = new Vector3(0f, 0.25f + num * 0.00625f, 0f);
			}
			else
			{
				this.fm = "m";
			}
			this._shoulderKey = "c" + this.fm + "_J_Shoulder_";
			this._armUpKey = "c" + this.fm + "_J_ArmUp00_";
			this._armLowKey = "c" + this.fm + "_J_ArmLow01_";
			this.quickAdjust = new QuickAdjust(this);
			this.ResetBoneNameMap();
			this.ResetRotationMap();
			this.lipNoList = new int[4];
			this.isSaveVMD = false;
		}

		public void ResetBoneNameMap()
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>
			{
				{this.fm + "_J_centor","センター"},
				{this.fm + "_J_slot","グルーブ"},
				{"c" + this.fm + "_J_Hips","腰"},
				{"c" + this.fm + "_J_Spine01","上半身"},
				{"c" + this.fm + "_J_Spine02","上半身2"},{"c" + this.fm + "_J_Spine03","上半身2先"},
				{"c" + this.fm + "_J_Neck","首"},
				{"c" + this.fm + "_J_Head","頭"},
				{"c" + this.fm + "_J_Shoulder_L","左肩"},
				{"c" + this.fm + "_J_ArmUp00_L","左腕"},
				{"c" + this.fm + "_J_ArmLow01_L","左ひじ"},
				{"c" + this.fm + "_J_Hand_L","左手首"},
				{"c" + this.fm + "_J_Shoulder_R","右肩"},
				{"c" + this.fm + "_J_ArmUp00_R","右腕"},
				{"c" + this.fm + "_J_ArmLow01_R","右ひじ"},
				{"c" + this.fm + "_J_Hand_R","右手首"},
				{"c" + this.fm + "_J_Kosi01","下半身"},
				{"c" + this.fm + "_J_Kosi02","下半身先"},
				{"c" + this.fm + "_J_LegUp00_L","左足"},
				{"c" + this.fm + "_J_LegLow01_L","左ひざ"},
				{"c" + this.fm + "_J_Foot01_L","左足首"},
				{"c" + this.fm + "_J_Toes01_L","左つま先"},
				{"c" + this.fm + "_J_LegUp00_R","右足"},
				{"c" + this.fm + "_J_LegLow01_R","右ひざ"},
				{"c" + this.fm + "_J_Foot01_R","右足首"},
				{"c" + this.fm + "_J_Toes01_R","右つま先"},
				{"c" + this.fm + "_J_Hand_Thumb02_L","左親指１"},
				{"c" + this.fm + "_J_Hand_Thumb03_L","左親指２"},
				{"c" + this.fm + "_J_Hand_Index01_L","左人指１"},
				{"c" + this.fm + "_J_Hand_Index02_L","左人指２"},
				{"c" + this.fm + "_J_Hand_Index03_L","左人指３"},
				{"c" + this.fm + "_J_Hand_Middle01_L","左中指１"},
				{"c" + this.fm + "_J_Hand_Middle02_L","左中指２"},
				{"c" + this.fm + "_J_Hand_Middle03_L","左中指３"},
				{"c" + this.fm + "_J_Hand_Ring01_L","左薬指１"},
				{"c" + this.fm + "_J_Hand_Ring02_L","左薬指２"},
				{"c" + this.fm + "_J_Hand_Ring03_L","左薬指３"},
				{"c" + this.fm + "_J_Hand_Little01_L","左小指１"},
				{"c" + this.fm + "_J_Hand_Little02_L","左小指２"},
				{"c" + this.fm + "_J_Hand_Little03_L","左小指３"},
				{"c" + this.fm + "_J_Hand_Thumb02_R","右親指１"},
				{"c" + this.fm + "_J_Hand_Thumb03_R","右親指２"},
				{"c" + this.fm + "_J_Hand_Index01_R","右人指１"},
				{"c" + this.fm + "_J_Hand_Index02_R","右人指２"},
				{"c" + this.fm + "_J_Hand_Index03_R","右人指３"},
				{"c" + this.fm + "_J_Hand_Middle01_R","右中指１"},
				{"c" + this.fm + "_J_Hand_Middle02_R","右中指２"},
				{"c" + this.fm + "_J_Hand_Middle03_R","右中指３"},
				{"c" + this.fm + "_J_Hand_Ring01_R","右薬指１"},
				{"c" + this.fm + "_J_Hand_Ring02_R","右薬指２"},
				{"c" + this.fm + "_J_Hand_Ring03_R","右薬指３"},
				{"c" + this.fm + "_J_Hand_Little01_R","右小指１"},
				{"c" + this.fm + "_J_Hand_Little02_R","右小指２"},
				{"c" + this.fm + "_J_Hand_Little03_R","右小指３"},
				{this.fm + "_pv_leg_L","左足ＩＫ"},
				{this.fm + "_pv_leg_R","右足ＩＫ"},
				{this.fm + "_pv_toe_L","左つま先ＩＫ"},
				{this.fm + "_pv_toe_R","右つま先ＩＫ"}
			};
			this.boneNameMap = dictionary;
		}

		public void AddBoneNameMap(string hsBone, string vmxBone)
		{
			this.boneNameMap[hsBone] = vmxBone;
		}

		public void SetCurrentRot(string name)
		{
			if (this.boneAdjust.ContainsKey(name) == false) return;
			this.lastAdjustedBone = name;
			this.lastModifiedAdjustment = this.boneAdjust[name];
		}

		public void RemoveBoneNameMap(string hsBone)
		{
			if (this.boneNameMap.ContainsKey(hsBone) == false) return;
			this.boneNameMap.Remove(hsBone);
		}

		public void ClearRotationMap()
		{
			this.boneAdjust = new Dictionary<string, BoneAdjustment>();
			this.lastAdjustedBone = null;
			this.lastModifiedAdjustment = null;
		}
		public void ResetRotationMap()
		{
			this.boneAdjust = new Dictionary<string, BoneAdjustment>();
			this.AddRotAxisMap(this.fm + "_J_centor", "x,y,z");
			this.AddRotAxisMap(this.fm + "_J_slot", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Hips", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Spine01", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Spine02", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Neck", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Head", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Shoulder_L", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_ArmUp00_L", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_ArmLow01_L", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Hand_L", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Shoulder_R", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_ArmUp00_R", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_ArmLow01_R", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Hand_R", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Kosi01", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Kosi02", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_LegUp00_L", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_LegLow01_L", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Foot01_L", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_LegUp00_R", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_LegLow01_R", "x,y,z");
			this.AddRotAxisMap("c" + this.fm + "_J_Foot01_R", "x,y,z");
			this.AddRotAxisMap(this.fm + "_pv_leg_L", "x,y,z");
			this.AddRotAxisMap(this.fm + "_pv_leg_R", "x,y,z");
			this.AddRotAxisMap(this.fm + "_pv_toe_L", "x,y,z");
			this.AddRotAxisMap(this.fm + "_pv_toe_R", "x,y,z");
			foreach (string text in new string[] { "L", "R" })
			{
				for (int j = 1; j <= 3; j++)
				{
					this.AddRotAxisMap(string.Concat(new object[] { "c", this.fm, "_J_Hand_Index0", j, "_", text }), "x,y,z");
					this.AddRotAxisMap(string.Concat(new object[] { "c", this.fm, "_J_Hand_Middle0", j, "_", text }), "x,y,z");
					this.AddRotAxisMap(string.Concat(new object[] { "c", this.fm, "_J_Hand_Ring0", j, "_", text }), "x,y,z");
					this.AddRotAxisMap(string.Concat(new object[] { "c", this.fm, "_J_Hand_Little0", j, "_", text }), "x,y,z");
					if (j != 3) { this.AddRotAxisMap(string.Concat(new object[] { "c", this.fm, "_J_Hand_Thumb0", j, "_", text }), "x,y,z"); }
				}
			}
			this.quickAdjust.Set();
			this.boneAdjust[this._armLowKey + "L"].rotAxisAdjustment = true;
			this.boneAdjust[this._armLowKey + "R"].rotAxisAdjustment = true;
			this.boneAdjust["c" + this.fm + "_J_Neck"].rotationScale = 0.5f;
		}

		public void AddRotAxisMap(string spec)
		{
			this.AddRotAxisMap(this.lastAdjustedBone, spec);
		}
		public void AddRotAxisMap(string hsBone, string spec)
		{
			try
			{
				if (hsBone == null) return;
				BoneAdjustment boneAdjustment = null;
				this.boneAdjust.TryGetValue(hsBone, out boneAdjustment);
				if (boneAdjustment == null)
				{
					boneAdjustment = BoneAdjustment.Init(hsBone, spec, Vector3.zero, false);
					this.boneAdjust[hsBone] = boneAdjustment;
				}
				else
				{
					boneAdjustment.SetSpec(spec);
				}
				this.lastAdjustedBone = hsBone;
				this.lastModifiedAdjustment = boneAdjustment;
			}
			catch (Exception arg)
			{
				Console.WriteLine("Parse error: {0}. {1}", spec, arg);
			}
		}

		public void AddRotationMap(string hsBone, float x, float y, float z, bool adjustAxis, float axisX, float axisY, float axisZ)
		{
			if (this.boneNameMap.ContainsKey(hsBone) == false) return;
			Vector3 rotAdjustment = new Vector3(x, y, z);
			Vector3 axisAdjustment = new Vector3(axisX, axisY, axisZ);
			BoneAdjustment boneAdjustment = null;
			this.boneAdjust.TryGetValue(hsBone, out boneAdjustment);
			if (boneAdjustment == null)
			{
				boneAdjustment = BoneAdjustment.Init(hsBone, "x,y,z", rotAdjustment, adjustAxis);
				boneAdjustment.SetAxisAdjustment(axisAdjustment);
				this.boneAdjust[hsBone] = boneAdjustment;
			}
			else
			{
				boneAdjustment.SetRotAdjustment(rotAdjustment);
				boneAdjustment.rotAxisAdjustment = adjustAxis;
				boneAdjustment.SetAxisAdjustment(axisAdjustment);
			}
			this.lastAdjustedBone = hsBone;
			this.lastModifiedAdjustment = boneAdjustment;
		}

		public void AddRotationMap(string hsBone, float x, float y, float z)
		{
			this.AddRotationMap(hsBone, x, y, z, false, 0f, 0f, 0f);
		}

		public void RemoveRotationMap(string hsBone)
		{
			if (this.boneAdjust.ContainsKey(hsBone) == false) return;
			this.boneAdjust[hsBone].SetRotAdjustment(Vector3.zero);
		}

		public void Dump()
		{
			using (StreamWriter streamWriter = File.CreateText("__rotinfo.txt"))
			{
				foreach (string text in this.boneAdjust.Keys)
				{
					BoneAdjustment boneAdjustment = this.boneAdjust[text];
					streamWriter.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", new object[]
					{
						text,
						boneAdjustment.spec,
						boneAdjustment.RotX,
						boneAdjustment.RotY,
						boneAdjustment.RotZ,
						boneAdjustment.rotAxisAdjustment
					});
				}
			}
		}

		public void ReloadVMDAnimation()
		{
			if (this.lastLoadedVMD == null) return;
			this.LoadVMDAnimation(this.lastLoadedVMD, this.lastLipPath);
		}
		public void LoadVMDAnimation(string path, string lipPath = null)
		{
			this.LoadVMDAnimation(path, true);
			this.LoadLipSync(lipPath, true);
		}
		public void LoadLipSync(string lipPath, bool isPlay)
		{
			this.vmdLipEnabled = true;
			this.lipAudioEnabled = false;
			this.charInfo.human.lipSync.SetAudioSource(null);
			if (!string.IsNullOrEmpty(lipPath))
			{
				string text = lipPath.Substring(lipPath.LastIndexOf(".") + 1, lipPath.Length - lipPath.LastIndexOf(".") - 1);
				if (text.ToLower().Equals("ogg") || text.ToLower().Equals("wav"))
				{
					this.lastLipPath = lipPath;
					if (this.audioSrc == null)
					{
						this.audioSrc = base.gameObject.AddComponent<AudioSource>();
						this.audioSrc.volume = 0f;
					}
					base.StartCoroutine(this.LoadAudioEnum(lipPath, isPlay));
					return;
				}
				if (text.ToLower().Equals("vmd"))
				{
					this.lastLipPath = lipPath;
					this.LoadVMDLipAnim(lipPath);
					return;
				}
				Console.WriteLine("Error Lip File Format!!");
			}
		}
		private IEnumerator LoadAudioEnum(string path, bool play)
		{
			Console.WriteLine("Load audio: " + path);
			WWW www = new WWW("file://" + path);
			yield return www;
			if (www != null && string.IsNullOrEmpty(www.error))
			{
				AudioClip audioClip = www.audioClip;
				this.audioSrc.clip = www.audioClip;
				this.vmdLipEnabled = false;
				this.lipAudioEnabled = true;
				if (play && this.isLipSync)
				{
					this.charInfo.human.lipSync.SetAudioSource(this.audioSrc);
					float num = this.GetAnimTime() - this.lipDelayTime;
					if (num > 0f)
					{
						this.audioSrc.time = num;
						this.audioSrc.Play();
					}
					else
					{
						float num2 = Mathf.Abs(num);
						this.audioSrc.time = 0f;
						this.audioSrc.PlayDelayed(num2);
					}
				}
			}
			yield break;
		}

		public void LoadVMDLipAnim(string path)
		{
			using (BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)))
			{
				VMDFormat vmdformat = new VMDFormat(binaryReader, path, "skin");
				if (vmdformat.skin_list != null)
					this.skinListVMD = vmdformat.skin_list;
				this.charInfo.human.lipSync.SetAudioSource(null);
			}
		}

		public void LoadVMDAnimation(string path, bool play)
		{
			try
			{
				if (this.charInfo == null) return;

				using (BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)))
				{
					VMDFormat vmdformat = VMDLoader.Load(binaryReader, path, this.clipname, this.isSaveVMD);
					this.ikSetListVMD = null;
					this.skinListVMD = null;
					if (this.animationForVMD == null)
						this.animationForVMD = this.charInfo.animBody.gameObject.AddComponent<Animation>();

					this.animationForVMD.Stop();
					this.ResetBones();
					this.InitializeBasePositions();
					this.SetIKTargets();
					var vmdConverter = new VMDHSConverter(boneNameMap, HSModelBaseline, boneAdjust, scale, centerBasePos, hipPositionAdjust, slotPositionAdjust, isBasePos, isUseSlot, isWaistLeg);
					AnimationClip animationClip = vmdConverter.CreateAnimationClip(vmdformat, charInfo.animBody.gameObject, 4);
					this.IKWeight.isLeftToeData = true;
					this.IKWeight.isRightToeData = true;
					animationClip.wrapMode = this.loop ? WrapMode.Loop : WrapMode.Once;
					this.lastLoadedVMD = path;
					this.clipname = "VMDAnim";
					this.animationForVMD.AddClip(animationClip, this.clipname);
					this.animationForVMD.clip = animationClip;
					this.animationForVMD[this.clipname].speed = this._speed;
					this.ikSetListVMD = vmdformat.ik_set_list;
					this.skinListVMD = vmdformat.skin_list;
					this.isLeftFootIK = true;
					this.isRightFootIK = true;
					this.isLeftToeIK = true;
					this.isRightToeIK = true;
					this.currentSetNo = 0;
					this.lipNoList[0] = 0;
					this.lipNoList[1] = 0;
					this.lipNoList[2] = 0;
					this.lipNoList[3] = 0;
					this.ikSwitch = true;
					if (play) this.animationForVMD.Play(this.clipname);
				}
			}
			catch (Exception value)
			{
				Console.WriteLine(value);
			}
		}

		private void SetIKTargets()
		{
			FullBodyBipedIK fullBodyIK = this.animeOverride.studioChara.fullBodyIK;
			fullBodyIK.solver.leftFootEffector.target = this.t_leftFootIK;
			fullBodyIK.solver.rightFootEffector.target = this.t_rightFootIK;
			fullBodyIK.solver.bodyEffector.target = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, this.fm + "_t_spine").transform;
			fullBodyIK.solver.leftThighEffector.target = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, this.fm + "_k_thigh_L").transform;
			fullBodyIK.solver.rightThighEffector.target = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, this.fm + "_k_thigh_R").transform;
			fullBodyIK.solver.leftLegChain.bendConstraint.bendGoal = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, this.fm + "_pv_knee_L").transform;
			fullBodyIK.solver.rightLegChain.bendConstraint.bendGoal = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, this.fm + "_pv_knee_R").transform;
		}

		public void SetLipSyn(bool isLipSyn)
		{
			if (this.isLipSync == isLipSyn) return;
			this.isLipSync = isLipSyn;
			if (this.isLipSync)
			{
				if (this.lipAudioEnabled && this.audioSrc != null)
				{
					this.charInfo.human.lipSync.SetAudioSource(this.audioSrc);
					this.audioSrc.time = this.GetAnimClip().time;
					this.audioSrc.Play();
					return;
				}
				return;
			}

			if (this.audioSrc != null) this.audioSrc.Stop();
			this.charInfo.human.lipSync.SetAudioSource(null);
			this.studioChara.ChangeMouthOpen(0f);
			this.studioChara.charInfo.ChangeMouthPtn(0);
			this.lastLipPath = null;
		}

		public void SetLipDelayEnabled(bool isDelay)
		{
			if (this.isLipDelay == isDelay) return;
			this.isLipDelay = isDelay;
			if (this.lipAudioEnabled && this.isLipDelay && this.audioSrc != null)
			{
				float num = this.GetAnimTime() - this.lipDelayTime;
				if (num > 0f) this.audioSrc.time = num;
			}
		}
		public void SetLipDelayTime(float delay)
		{
			if (delay == this.lipDelayTime) return;
			this.lipDelayTime = delay;
			if (this.lipAudioEnabled && this.isLipDelay && this.audioSrc != null)
			{
				float num = this.GetAnimTime() - this.lipDelayTime;
				if (num > 0f) this.audioSrc.time = num;
			}
		}
		public void Play()
		{
			if (this.clipname == null) return;
			if (this.vmdAnimEnabled==false) return;

			if (!this.GetAnimation().isPlaying)
			{
				this.currentSetNo = 0;
				this.lipNoList[0] = 0;
				this.lipNoList[1] = 0;
				this.lipNoList[2] = 0;
				this.lipNoList[3] = 0;
			}
			this.GetAnimation()[this.clipname].speed = this._speed;
			this.GetAnimation().Play(this.clipname);
			if (this.audioSrc != null && this.isLipSync && this.lipAudioEnabled)
			{
				if (this.isLipDelay)
				{
					float num = this.GetAnimTime() - this.lipDelayTime;
					if (num > 0f)
					{
						this.audioSrc.time = num;
						this.audioSrc.Play();
						return;
					}
					float num2 = Mathf.Abs(num);
					this.audioSrc.time = 0f;
					this.audioSrc.PlayDelayed(num2);
					return;
				}
				else
				{
					this.audioSrc.Play();
				}
			}
		}

		public void Pause()
		{
			if (this.clipname == null) return;
			if (this.vmdAnimEnabled == false) return;
			this.GetAnimation()[this.clipname].speed = 0f;
			if (this.audioSrc != null)
				this.audioSrc.Pause();
		}

		public void Stop()
		{
			if (this.clipname == null) return;
			if (this.vmdAnimEnabled == false) return;

			this.GetAnimation().Stop(this.clipname);
			this.currentSetNo = 0;
			this.lipNoList[0] = 0;
			this.lipNoList[1] = 0;
			this.lipNoList[2] = 0;
			this.lipNoList[3] = 0;
			if (this.audioSrc != null)
				this.audioSrc.Stop();
		}

		public void Restart()
		{
			if (this.clipname == null) return;
			if (this.vmdAnimEnabled == false) return;

			Animation animation = this.GetAnimation();
			animation[this.clipname].normalizedTime = 0f;
			animation[this.clipname].speed = this._speed;
			this.currentSetNo = 0;
			this.lipNoList[0] = 0;
			this.lipNoList[1] = 0;
			this.lipNoList[2] = 0;
			this.lipNoList[3] = 0;
			animation.Play(this.clipname);
		}

		public void SetAnimPosition(float time)
		{
			if (this.clipname == null) return;
			if (this.vmdAnimEnabled == false) return;

			this.GetAnimation()[this.clipname].time = time;
		}

		private void DisableEnableDefaultAnim()
		{
			if (this.vmdAnimEnabled)
			{
				this.ResetBoneRotations();
				this.animeOverride.DisableBreastDynamicBoneAndAnime();
				this.SetIKTargets();
				return;
			}
			this.animeOverride.RestoreDefaultIKTargets();
			this.animeOverride.ResetBreastAnimeDynamicBoneState();
		}

		private void ResetEffectorWeight()
		{
			if (this.vmdAnimEnabled == false) return;
			foreach (IKEffector ikeffector in this.animeOverride.studioChara.fullBodyIK.solver.effectors)
			{
				ikeffector.positionWeight = 0f;
				ikeffector.rotationWeight = 0f;
			}
			FBIKChain[] chain = this.animeOverride.studioChara.fullBodyIK.solver.chain;
			for (int j = 0; j < chain.Length; j++)
			{
				chain[j].bendConstraint.weight = 0f;
			}
		}

		private void Update()
		{
			if (this.VMDAnimEnabled == false) return;
			FullBodyBipedIK fullBodyIK = this.animeOverride.studioChara.fullBodyIK;
			Animation animation = this.GetAnimation();
			if (animation == null) return;
			if (this.ikSetListVMD != null && this.currentSetNo < this.ikSetListVMD.ik_set_count)
			{
				AnimationState animClip = this.GetAnimClip();
				AnimationClip clip = animClip.clip;
				float num = animClip.length * animClip.normalizedTime * clip.frameRate / 2f;
				VMDFormat.IKSetData iksetData = this.ikSetListVMD.ik_set[this.currentSetNo];
				while (iksetData.flame_no <= num)
				{
					if (iksetData.ik_frame_map.ContainsKey("右足ＩＫ"))
					{
						this.isRightFootIK = iksetData.ik_frame_map["右足ＩＫ"];
					}
					if (iksetData.ik_frame_map.ContainsKey("左足ＩＫ"))
					{
						this.isLeftFootIK = iksetData.ik_frame_map["左足ＩＫ"];
					}
					if (iksetData.ik_frame_map.ContainsKey("右つま先ＩＫ"))
					{
						this.isRightToeIK = iksetData.ik_frame_map["右つま先ＩＫ"];
					}
					if (iksetData.ik_frame_map.ContainsKey("左つま先ＩＫ"))
					{
						this.isLeftToeIK = iksetData.ik_frame_map["左つま先ＩＫ"];
					}
					this.currentSetNo++;
					if ((long)this.currentSetNo >= (long)((ulong)this.ikSetListVMD.ik_set_count))
					{
						break;
					}
					iksetData = this.ikSetListVMD.ik_set[this.currentSetNo];
				}
				this.ikSwitch = this.isRightFootIK || this.isLeftFootIK || this.isRightToeIK || this.isLeftToeIK;
			}
			if (this.enableIK && this.ikSwitch && animation.isPlaying && !fullBodyIK.enabled)
			{
				this.animeOverride.IKUpdate();
			}
			this.animeOverride.DisableBreastDynamicBoneAndAnime();
			if (this.vmdLipEnabled && this.isLipSync && this.skinListVMD != null)
			{
				AnimationState animClip2 = this.GetAnimClip();
				AnimationClip clip2 = animClip2.clip;
				float frameNo = animClip2.length * animClip2.normalizedTime * clip2.frameRate / 2f;
				float lipWeight = this.GetLipWeight(0, frameNo);
				float lipWeight2 = this.GetLipWeight(1, frameNo);
				float lipWeight3 = this.GetLipWeight(2, frameNo);
				float lipWeight4 = this.GetLipWeight(3, frameNo);
				float num2 = lipWeight * 1.5f + lipWeight2 / 3.4f + lipWeight3 * 0.7f + lipWeight4 * 0.75f;
				int num3 = 0;
				int mouthPtn = this.studioChara.charInfo.GetMouthPtn();
				if (num2 > 1.65f)
				{
					num2 -= 1.6f;
					num3 = 18;
				}
				else if (num2 > 1f)
				{
					num2 -= 0.65f;
					num3 = 6;
				}
				if (num3 != mouthPtn)
				{
					Info.ExpressionInfo expressionInfo = (this.studioChara.charInfo.sex != 1) ? Singleton<Info>.Instance.dicMaleMouth[num3] : Singleton<Info>.Instance.dicFemaleMouth[num3];
					this.studioChara.charInfo.fileStatus.mouthPtn = num3;
					this.studioChara.charInfo.human.ExpressionPlay(1, expressionInfo.clip, 0f);
				}
				this.studioChara.ChangeMouthOpen(num2);
			}
			AutoTrackObjectMgr.Instance.RegisterLateUpdateLock(this);
		}

		private float GetLipWeight(int keyNum, float frameNo)
		{
			string key = this.lipStringList[keyNum];
			int num = this.lipNoList[keyNum];
			if (this.skinListVMD.skin.ContainsKey(key) == false) return 0;
			List<VMDFormat.SkinData> list = this.skinListVMD.skin[key];
			if (num >= list.Count) return 0;
			VMDFormat.SkinData skinData = list[num];
			while (skinData.flame_no <= frameNo)
			{
				num++;
				if (num >= list.Count) break;
				skinData = list[num];
			}
			return skinData.weight;
		}

		private void LateUpdate()
		{
			try
			{
				if (this.charInfo == null) return;
				Animation animation = this.GetAnimation();
				if (!(animation == null) && animation.isPlaying)
				{
					try
					{
						FullBodyBipedIK fullBodyIK = this.animeOverride.studioChara.fullBodyIK;
						if (this.VMDAnimEnabled)
						{
							IKSolverFullBodyBiped solver = fullBodyIK.solver;
							foreach (IKEffector ikeffector in solver.effectors)
							{
								ikeffector.positionWeight = 0f;
								ikeffector.rotationWeight = 0f;
							}
							FBIKChain[] chain = solver.chain;
							for (int j = 0; j < chain.Length; j++)
							{
								chain[j].bendConstraint.weight = 0f;
							}
							fullBodyIK.solver.leftLegChain.bendConstraint.weight = this.IKWeight.footIKRotWeight;
							fullBodyIK.solver.rightLegChain.bendConstraint.weight = this.IKWeight.footIKRotWeight;
							solver.bodyEffector.positionWeight = 0f;
							solver.bodyEffector.rotationWeight = 0f;
							if (this.isLeftFootIK)
							{
								solver.leftLegMapping.weight = 1f;
								solver.SetEffectorWeights(FullBodyBipedEffector.LeftFoot, this.IKWeight.footIKPosWeight, this.IKWeight.footIKRotWeight);
							}
							if (this.isRightFootIK)
							{
								solver.rightLegMapping.weight = 1f;
								solver.SetEffectorWeights(FullBodyBipedEffector.RightFoot, this.IKWeight.footIKPosWeight, this.IKWeight.footIKRotWeight);
							}
							solver.leftArmChain.pin = 1f;
							solver.leftArmChain.pull = 0f;
							solver.rightArmChain.pin = 1f;
							solver.rightArmChain.pull = 0f;
							if (this.enableIK && this.ikSwitch)
							{
								if (this.enableIK2)
								{
									this.animeOverride.IKLateUpdate();
								}
								if (this.isLeftFootIK && this.enableIK3)
								{
									CCDIKSolver legIK = this.GetLegIK(this.t_leftFootIK, solver.leftLegMapping);
									legIK.controll_weight = this.IKWeight.footControlWeight;
									legIK.iterations = this.IKWeight.footIteration;
									legIK.useLeg = true;
									legIK.Solve();
								}
								if (this.isRightFootIK && this.enableIK3)
								{
									CCDIKSolver legIK2 = this.GetLegIK(this.t_rightFootIK, solver.rightLegMapping);
									legIK2.controll_weight = this.IKWeight.footControlWeight;
									legIK2.iterations = this.IKWeight.footIteration;
									legIK2.useLeg = true;
									legIK2.Solve();
								}
								if (this.isLeftToeIK && this.IKWeight.disableToeIK == 0)
								{
									this.EasyToeIK(this.t_leftFoot, this.t_leftToeIK, this.t_leftFootIK, this.HSModelBaseline.leftFootUp);
								}
								if (this.isRightToeIK && this.IKWeight.disableToeIK == 0)
								{
									this.EasyToeIK(this.t_rightFoot, this.t_rightToeIK, this.t_rightFootIK, this.HSModelBaseline.rightFootUp);
								}
								this.lToeIK.solver.IKPositionWeight = 0f;
								this.rToeIK.solver.IKPositionWeight = 0f;
								if (this.isLeftToeIK && this.IKWeight.disableToeIK == 1 && this.IKWeight.isLeftToeData)
								{
									CCDIKSolver toeIK = this.GetToeIK(this.t_leftFoot, this.t_leftToe, this.t_leftToeIK, this.t_leftHeel);
									toeIK.controll_weight = this.IKWeight.toeControlWeight;
									toeIK.iterations = this.IKWeight.toeIteration;
									toeIK.Solve();
								}
								if (this.isRightToeIK && this.IKWeight.disableToeIK == 1 && this.IKWeight.isRightToeData)
								{
									CCDIKSolver toeIK2 = this.GetToeIK(this.t_rightFoot, this.t_rightToe, this.t_rightToeIK, this.t_rightHeel);
									toeIK2.controll_weight = this.IKWeight.toeControlWeight;
									toeIK2.iterations = this.IKWeight.toeIteration;
									toeIK2.Solve();
								}
								if (this.isLeftFootIK && this.enableIK2)
								{
									this.fixedIKBone(this.t_leftKnee, this.t_leftFoot);
								}
								if (this.isRightFootIK && this.enableIK2)
								{
									this.fixedIKBone(this.t_rightKnee, this.t_rightFoot);
								}
							}
							this.animeOverride.CalculateBreastDynamicBone();
							this.ikMorphFix.DoFix3();
							this.ikMorphFix.UpdateDhh();
						}
					}
					catch (Exception value)
					{
						Console.WriteLine(value);
					}
				}
			}
			finally
			{
				if (this.VMDAnimEnabled)
				{
					AutoTrackObjectMgr.Instance.ReleaseLateUpdateLock(this);
				}
			}
		}
		private void fixIKBones(Transform[] bone)
		{
			for (int i = 0; i < bone.Length - 1; i++)
			{
				this.fixedIKBone(bone[i], bone[i + 1]);
			}
		}
		private void fixedIKBone(Transform bone, Transform bone_c)
		{
			Quaternion rotation = bone_c.rotation;
			Vector3 localEulerAngles = bone.localEulerAngles;
			if (CCDIKSolver.adjust_rot(localEulerAngles.y) == CCDIKSolver.adjust_rot(localEulerAngles.z))
			{
				localEulerAngles.y = (float)CCDIKSolver.adjust_rot(localEulerAngles.y);
				localEulerAngles.z = (float)CCDIKSolver.adjust_rot(localEulerAngles.z);
			}
			if (localEulerAngles.x > 180f) localEulerAngles.x -= 360f;
			if (localEulerAngles.x < 0f) localEulerAngles.x = 0f;
			else if (localEulerAngles.x > 170f) localEulerAngles.x = 170f;
			bone.localRotation = Quaternion.Euler(localEulerAngles);
			bone_c.rotation = rotation;
		}
		private void ResetBones()
		{
			this.DisableEnableDefaultAnim();
			FullBodyBipedIK fullBodyIK = this.animeOverride.studioChara.fullBodyIK;
			foreach (IKEffector ikeffector in fullBodyIK.solver.effectors)
			{
				if (ikeffector.bone != null && ikeffector.bone.name.Contains("c" + this.fm + "_J_Foot01_"))
				{
					ikeffector.positionWeight = this.IKWeight.footIKPosWeight;
					ikeffector.rotationWeight = this.IKWeight.footIKRotWeight;
				}
				else
				{
					ikeffector.positionWeight = 0f;
					ikeffector.rotationWeight = 0f;
				}
			}
			fullBodyIK.solver.leftArmChain.pull = 0f;
			fullBodyIK.solver.rightArmChain.pull = 0f;
			this.t_height = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_N_height").transform;
			this.t_hips = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_Hips").transform;
			this.t_leftLeg = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_LegUp00_L").transform;
			this.t_rightLeg = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_LegUp00_R").transform;
			this.t_leftKnee = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_LegLow01_L").transform;
			this.t_rightKnee = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_LegLow01_R").transform;
			this.t_leftFoot = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_Foot01_L").transform;
			this.t_rightFoot = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_Foot01_R").transform;
			this.t_leftHeel = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_Foot02_L").transform;
			this.t_rightHeel = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_Foot02_R").transform;
			this.t_leftFootIK = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, this.fm + "_pv_leg_L").transform;
			this.t_rightFootIK = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, this.fm + "_pv_leg_R").transform;
			this.t_leftToe = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_Toes01_L").transform;
			this.t_rightToe = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, "c" + this.fm + "_J_Toes01_R").transform;
			this.t_leftToeIK = this.t_leftFootIK.FindChild(this.fm + "_pv_toe_L");
			this.t_rightToeIK = this.t_rightFootIK.FindChild(this.fm + "_pv_toe_R");
			GameObject gameObject = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, this.fm + "_J_centor");
			if (gameObject != null)
			{
				this.t_centor = gameObject.transform;
				this.t_hips.parent = this.t_height;
			}
			else
			{
				this.t_centor = new GameObject(this.fm + "_J_centor").transform;
				this.t_centor.parent = this.t_height;
				this.t_centor.localRotation = Quaternion.identity;
				this.t_centor.localScale = Vector3.one;
			}
			GameObject gameObject2 = TransformFindEx.FindLoop(this.charInfo.objBodyBone.transform, this.fm + "_J_slot");
			if (gameObject2 != null)
			{
				this.t_slot = gameObject2.transform;
				this.t_slot.parent = this.t_height;
			}
			else
			{
				this.t_slot = new GameObject(this.fm + "_J_slot").transform;
				this.t_slot.parent = this.t_height;
				this.t_slot.localRotation = Quaternion.identity;
				this.t_slot.localScale = Vector3.one;
			}
			if (this.t_leftToeIK == null)
			{
				this.t_leftToeIK = new GameObject(this.fm + "_pv_toe_L").transform;
				this.t_leftToeIK.parent = this.t_leftFootIK;
				this.t_leftToeIK.localPosition = Vector3.forward * 0.03f;
				this.t_leftToeIK.localRotation = Quaternion.identity;
				this.t_leftToeIK.localScale = Vector3.one;
			}
			if (this.t_rightToeIK == null)
			{
				this.t_rightToeIK = new GameObject(this.fm + "_pv_toe_R").transform;
				this.t_rightToeIK.parent = this.t_rightFootIK;
				this.t_rightToeIK.localPosition = Vector3.forward * 0.03f;
				this.t_rightToeIK.localRotation = Quaternion.identity;
				this.t_rightToeIK.localScale = Vector3.one;
			}
			this.lToeIK = this.GetToeIK2(this.t_leftFoot, this.t_leftToe, this.t_leftHeel, this.t_leftToeIK);
			this.rToeIK = this.GetToeIK2(this.t_rightFoot, this.t_rightToe, this.t_rightHeel, this.t_rightToeIK);
		}

		private void InitializeBasePositions()
		{
			this.ResetBoneRotations();
			this.t_centor.localRotation = Quaternion.identity;
			this.t_centor.localScale = Vector3.one;
			this.t_slot.localRotation = Quaternion.identity;
			this.t_slot.localScale = Vector3.one;
			Transform transform = this.charInfo.objBodyBone.transform;
			this.t_centor.position = transform.position + this.centerBasePos * this.scale;
			this.t_slot.position = this.t_centor.position + this.slotPositionAdjust * this.scale;
			this.HSModelBaseline.hipsPos = transform.InverseTransformPoint(this.t_hips.transform.position);
			this.HSModelBaseline.leftFootPos = transform.InverseTransformPoint(this.t_leftFoot.transform.position);
			this.HSModelBaseline.leftToePos = transform.InverseTransformPoint(this.t_leftToe.transform.position);
			this.HSModelBaseline.leftToePosRel = this.t_leftFoot.InverseTransformPoint(this.t_leftToe.position);
			this.HSModelBaseline.rightFootPos = transform.InverseTransformPoint(this.t_rightFoot.transform.position);
			this.HSModelBaseline.rightToePos = transform.InverseTransformPoint(this.t_rightToe.transform.position);
			this.HSModelBaseline.rightToePosRel = this.t_rightFoot.InverseTransformPoint(this.t_rightToe.position);
			this.t_leftFootIK.position = this.t_leftFoot.position;
			this.t_leftToeIK.position = this.t_leftToe.position;
			this.t_rightFootIK.position = this.t_rightFoot.position;
			this.t_rightToeIK.position = this.t_rightToe.position;
			this.HSModelBaseline.leftFootUp = new Vector3(0f, 0f, 0.217116f) - this.HSModelBaseline.leftToePosRel;
			this.HSModelBaseline.rightFootUp = new Vector3(0f, 0f, 0.217116f) - this.HSModelBaseline.rightToePosRel;
			this.HSModelBaseline.centerPos = transform.InverseTransformPoint(this.t_centor.transform.position);
			this.HSModelBaseline.slotPos = transform.InverseTransformPoint(this.t_slot.transform.position);
			if (this.isUseSlot)
			{
				this.t_slot.parent = this.t_centor;
				this.t_hips.parent = this.t_slot;
			}
		}

		public void ResetBoneRotations()
		{
			this.animeOverride.ResetBoneRotations(false);
		}
		private CCDIK GetToeIK2(Transform foot, Transform toe, Transform heel, Transform toeIK)
		{
			CCDIK ccdik = toe.gameObject.GetComponent<CCDIK>();
			if (ccdik == null)
			{
				ccdik = toe.gameObject.AddComponent<CCDIK>();
				Transform[] array = new Transform[] { toe, heel, foot };
				ccdik.solver.SetChain(array, toe);
			}
			return ccdik;
		}

		private CCDIKSolver GetLegIK(Transform footIK, IKMappingLimb limb)
		{
			CCDIKSolver ccdiksolver = footIK.gameObject.GetComponent<CCDIKSolver>();
			if (ccdiksolver == null)
			{
				ccdiksolver = footIK.gameObject.AddComponent<CCDIKSolver>();
				ccdiksolver.target = limb.bone3;
				ccdiksolver.chains = new Transform[] { limb.bone2, limb.bone1 };
			}
			return ccdiksolver;
		}
		private void EasyToeIK(Transform foot, Transform toeIK, Transform footIK, Vector3 diffUp)
		{
			Vector3 position = toeIK.position;
			toeIK.localPosition += diffUp;
			foot.LookAt(toeIK);
			toeIK.position = position;
			Vector3 localEulerAngles = foot.localEulerAngles;
			if (localEulerAngles.z > 5f) localEulerAngles.z = 5f;
			if (localEulerAngles.z < -5f) localEulerAngles.z = -5f;
			foot.localRotation = Quaternion.Euler(localEulerAngles);
		}

		private CCDIKSolver GetToeIK(Transform foot, Transform toe, Transform toeIK, Transform heel)
		{
			CCDIKSolver ccdiksolver = toeIK.gameObject.GetComponent<CCDIKSolver>();
			if (ccdiksolver == null)
			{
				ccdiksolver = toeIK.gameObject.AddComponent<CCDIKSolver>();
				ccdiksolver.target = toe;
				ccdiksolver.chains = new Transform[] { foot };
			}
			return ccdiksolver;
		}
		private void OnDestroy()
		{
			base.StopAllCoroutines();
			BaseMgr<HSVMDAnimationMgr>.Instance.controllers.Remove(this);
		}
		private Animation GetAnimation()
		{
			return this.animationForVMD;
		}
		private void SetSpeed(float speed)
		{
			Animation animation = this.GetAnimation();
			if (this.clipname == null) return;
			if (animation == null) return;
			animation[this.clipname].speed = speed;
		}
		private float GetSpeed()
		{
			Animation animation = this.GetAnimation();
			if (this.clipname == null) return 0f;
			if (animation == null) return 0f;
			return animation[this.clipname].speed;
		}
		public float GetAnimTime()
		{
			if (this.clipname == null) return 0f;
			return this.GetAnimation()[this.clipname].time;
		}
		public AnimationState GetAnimClip()
		{
			if (this.clipname == null) return null;
			return this.GetAnimation()[this.clipname];
		}
		public void DeleteAnim()
		{
			Animation animation = this.GetAnimation();
			if (this.clipname == null) return;
			if (animation == null) return;
			AnimationClip clip = animation.GetClip(this.clipname);
			if (clip != null) animation.RemoveClip(clip);
			this.clipname = null;
		}

		private void OnVMDAnimEnabledChanged()
		{
			this.DisableEnableDefaultAnim();
			if (this.animationForVMD == null) return;
			this.animationForVMD.enabled = this.vmdAnimEnabled;
		}
		
		public class IKWeightData
		{
			public int disableToeIK;
			public float footIKPosWeight = 1f;
			public float footIKRotWeight;
			public int footIteration = 40;
			public float footControlWeight = 0.02f;
			public int toeIteration = 3;
			public float toeControlWeight = 0.4f;
			public bool isLeftToeData;
			public bool isRightToeData;
		}

		public class QuickAdjust
		{
			private HSVMDAnimationController mgr;
			private float _shoulder = 10f;
			private float _armUp = 30f;
			private float _armLow;
			private float _scaleModel = 1f;
			public QuickAdjust(HSVMDAnimationController mgr)
			{
				this.mgr = mgr;
			}

			public void Set()
			{
				try
				{
					float num = -this._shoulder;
					float num2 = -this._armUp;
					float num3 = -this._armLow;
					this.mgr.boneAdjust[this.mgr._shoulderKey + "L"].SetRotAdjustment(new Vector3(0f, 0f, num));
					this.mgr.boneAdjust[this.mgr._shoulderKey + "R"].SetRotAdjustment(new Vector3(0f, 0f, -1f * num));
					this.mgr.boneAdjust[this.mgr._armUpKey + "L"].SetRotAdjustment(new Vector3(0f, 0f, num2));
					this.mgr.boneAdjust[this.mgr._armUpKey + "R"].SetRotAdjustment(new Vector3(0f, 0f, -1f * num2));
					this.mgr.boneAdjust[this.mgr._armLowKey + "L"].SetRotAdjustment(new Vector3(0f, 0f, num3));
					this.mgr.boneAdjust[this.mgr._armLowKey + "R"].SetRotAdjustment(new Vector3(0f, 0f, -1f * num3));
					this.mgr.boneAdjust[this.mgr._armUpKey + "L"].SetAxisAdjustment(new Vector3(0f, 0f, -1f * num));
					this.mgr.boneAdjust[this.mgr._armUpKey + "R"].SetAxisAdjustment(new Vector3(0f, 0f, num));
					this.mgr.boneAdjust[this.mgr._armLowKey + "L"].SetAxisAdjustment(new Vector3(0f, 0f, -1f * num2));
					this.mgr.boneAdjust[this.mgr._armLowKey + "R"].SetAxisAdjustment(new Vector3(0f, 0f, num2));
					this.mgr.scale = this.mgr.scaleBase * this._scaleModel;
				}
				catch (Exception value)
				{
					Console.WriteLine(value);
				}
			}
			public float Shoulder
			{
				get { return this._shoulder; }
				set
				{
					if (this._shoulder == value) return;
					this._shoulder = value;
					this.Set();
				}
			}
			public float ArmUp
			{
				get { return this._armUp; }
				set
				{
					if (this._armUp == value) return;
					this._armUp = value;
					this.Set();
				}
			}
			public float ArmLow
			{
				get { return this._armLow; }
				set
				{
					if (this._armLow == value) return;
					this._armLow = value;
					this.Set();
				}
			}
			public float ScaleModel
			{
				get { return this._scaleModel; }
				set
				{
					if (this._scaleModel == value) return;
					this._scaleModel = value;
					this.Set();
				}
			}
		}
	}
}
